﻿using Orchard.ContentManagement.MetaData;
using Orchard.Core.Contents.Extensions;
using Orchard.Data.Migration;
using System;

namespace Vitus.Featured
{
    public class VitusFeaturedMigrations : DataMigrationImpl
    {
        public int Create()
        {
            SchemaBuilder.CreateTable("FeaturedPartRecord", table => table
                .ContentPartRecord()
                .Column<bool>("IsFeatured")
                .Column<string>("Title", column => column.WithLength(255))
                .Column<string>("Body", column => column.Unlimited())
                .Column<bool>("IsPinned")
            );

            ContentDefinitionManager.AlterPartDefinition("FeaturedPart", part => part
                .Attachable()
                .WithDescription("Content part used by the Featured widget to select and display featured content."));

            return 1;
        }
    }
}